package com.gjzt.business.task.controller;

import net.sf.json.JSONObject;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.eastdigit.servlet.RequestAttribute;
import com.eastdigit.servlet.Response;
import com.eastdigit.servlet.ReqBean;
import com.gjzt.business.task.service.CheckTaskService;

@Controller
@RequestMapping(value = "/checkTask")
public class CheckTaskController {

    @Autowired
    private CheckTaskService checkTaskService;

    /**
     * 查询
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/query")
    @ResponseBody
    public JSONObject queryTaskList(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        return Response.response(checkTaskService.findCheckTask(reqBean));
    }

    /**
     * 手机端检查任务查询
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/mobileQuery")
    @ResponseBody
    public JSONObject mobileQuery(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        return Response.response(checkTaskService.mobileQuery(reqBean));
    }




    /**
     * 手机端任务明细清单
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/mobileQueryItem")
    @ResponseBody
    public JSONObject mobileQueryItem(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        return Response.response(checkTaskService.mobileQueryItem(reqBean));
    }

    /**
     * 手机端任务检查图片查询
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/checkTaskImgs")
    @ResponseBody
    public JSONObject checkTaskImgs(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        return Response.response(checkTaskService.checkTaskImgs(reqBean));
    }

    /**
     * 手机端检查任务详情
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/mobileCheckDetail")
    @ResponseBody
    public JSONObject mobileCheckDetail(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        return Response.response(checkTaskService.mobileCheckDetail(reqBean));
    }



    /**
     * 手机端上刊单照片查询
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/mobilePublishImgQuery")
    @ResponseBody
    public JSONObject mobilePublishImgQuery(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        return Response.response(checkTaskService.mobilePublishImgQuery(reqBean));
    }


    /**
     * 手机端检查结果保存
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/saveCheckResult")
    @ResponseBody
    public JSONObject saveCheckResult(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        checkTaskService.saveCheckResult(reqBean);
        return Response.responseSuccess();
    }



    /**
     * 查询更新时对应的模版
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/queryTemplates")
    @ResponseBody
    public JSONObject queryTemplates(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        return Response.response(checkTaskService.queryTemplates(reqBean));
    }



    /**
     * 查询不同类别的清单明细数据
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/dynamicData")
    @ResponseBody
    public JSONObject dynamicData(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        return Response.response(checkTaskService.dynamicData(reqBean));
    }

    /**
     * 为回显而查询的所有不同的清单明细，不带分页
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/dynamicData4ReShow")
    @ResponseBody
    public JSONObject dynamicData4ReShow(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        return Response.response(checkTaskService.dynamicData4ReShow(reqBean));
    }

    /**
     * 查询不同类别的清单明细表头
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/dynamicHead")
    @ResponseBody
    public JSONObject dynamicHead(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        return Response.response(checkTaskService.dynamicHead(reqBean));
    }

    /**
     * 检查详情查看
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/checkTaskItemMore")
    @ResponseBody
    public JSONObject checkTaskItemMore(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        return Response.response(checkTaskService.checkTaskItemMore(reqBean));
    }

    /**
     * 检查详情查看
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/adCheckCheckTaskQuery")
    @ResponseBody
    public JSONObject adCheckCheckTaskQuery(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        return Response.response(checkTaskService.adCheckCheckTaskQuery(reqBean));
    }



    /**
     * 查询检查结果
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/checkResult")
    @ResponseBody
    public JSONObject checkResult(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        return Response.response(checkTaskService.checkResult(reqBean));
    }


    /**
     * 添加
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public JSONObject addCheckTask(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        checkTaskService.addCheckTask(reqBean);
        return Response.responseSuccess();
    }

    /**
     * 保存检查明细
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/saveSelectItem")
    @ResponseBody
    public JSONObject saveSelectItem(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        checkTaskService.saveSelectItem(reqBean);
        return Response.responseSuccess();
    }



    /**
     * 保存检查项
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/saveTemplates")
    @ResponseBody
    public JSONObject saveTemplates(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        checkTaskService.saveTemplates(reqBean);
        return Response.responseSuccess();
    }

    /**
     * 删除检查明细
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/checkItemDelete")
    @ResponseBody
    public JSONObject checkItemDelete(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        checkTaskService.checkItemDelete(reqBean);
        return Response.responseSuccess();
    }



    /**
     * 修改
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public JSONObject updateCheckTask(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        checkTaskService.updateCheckTask(reqBean);
        return Response.responseSuccess();
    }

    /**
     * 删除
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public JSONObject removeCheckTask(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        checkTaskService.removeCheckTask(reqBean);
        return Response.responseSuccess();
    }
    
    /**
     * 发布
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/release")
    @ResponseBody
    public JSONObject releaseCheckTask(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        checkTaskService.releaseCheckTask(reqBean);
        return Response.responseSuccess();
    }
    
    /**
     * 完成
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/finish")
    @ResponseBody
    public JSONObject finishCheckTask(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        checkTaskService.finishCheckTask(reqBean);
        return Response.responseSuccess();
    }

    //TODO 其他功能
}